/**
 * 
 */
package com.zzu.icukangfu.config;

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.ext.handler.ContextPathHandler;
import com.jfinal.kit.PathKit;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.render.ViewType;
import com.jfinal.template.Engine;
import com.zzu.icukangfu.controller.PatientController;
import com.zzu.icukangfu.controller.PhysicianController;
import com.zzu.icukangfu.controller.UserController;
import com.zzu.icukangfu.entity.Family;
import com.zzu.icukangfu.entity.Machine;
import com.zzu.icukangfu.entity.MachineT;
import com.zzu.icukangfu.entity.Patient;
import com.zzu.icukangfu.entity.PatientTM;
import com.zzu.icukangfu.entity.Physician;
import com.zzu.icukangfu.entity.User;


/**
 * @author teng
 * @time下午3:46:41
 * @corporation ttkj
 */
public class IcuConfig extends JFinalConfig{
	
	/* (non-Javadoc)
	 * @see com.jfinal.config.JFinalConfig#configConstant(com.jfinal.config.Constants)
	 */
	@Override
	public void configConstant(Constants me) {
		
		PropKit.use("a_little_config.txt");
		//PropertyConfigurator.configure("log4j.properties");
		me.setDevMode(false);
		me.setViewType(ViewType.FREE_MARKER);
		//设置默认图片存储地址
		me.setBaseUploadPath(PathKit.getWebRootPath());
		
		
	}

	/* (non-Javadoc)
	 * @see com.jfinal.config.JFinalConfig#configRoute(com.jfinal.config.Routes)
	 */
	@Override
	public void configRoute(Routes me) {
		/**
		 * 路由访问
		 */
		//设置基路径
		me.add("/patient",PatientController.class);
		me.add("/user",UserController.class);
		me.add("/physician",PhysicianController.class);
		/*me.setBaseViewPath("/html/");*/
		/*me.add("/machine",MachineController.class);*/
		
	}

	/* (non-Javadoc)
	 * @see com.jfinal.config.JFinalConfig#configEngine(com.jfinal.template.Engine)
	 */
	@Override
	public void configEngine(Engine me) {
		// TODO Auto-generated method stub
		
	}

	/* (non-Javadoc)
	 * @see com.jfinal.config.JFinalConfig#configPlugin(com.jfinal.config.Plugins)
	 */
	@Override
	public void configPlugin(Plugins me) {
		// TODO Auto-generated method stub
		
		loadPropertyFile("a_little_config.txt");
		DruidPlugin druid=new DruidPlugin(getProperty("jdbcUrl"),getProperty("user"),getProperty("password"));
		me.add(druid);
		ActiveRecordPlugin arp=new ActiveRecordPlugin(druid);
		me.add(arp);
		arp.addMapping("patient", Patient.class);
		arp.addMapping("user", User.class);
		arp.addMapping("family", Family.class);
		arp.addMapping("patient_tm", PatientTM.class);
		arp.addMapping("physician",Physician.class);
		arp.addMapping("machine", Machine.class);
		arp.addMapping("machine_t", MachineT.class);
		/*arp.addMapping("machine", Machine.class);
		arp.addMapping("machine_message", MachineMessage.class);*/
		
		
	}

	/* (non-Javadoc)
	 * @see com.jfinal.config.JFinalConfig#configInterceptor(com.jfinal.config.Interceptors)
	 */
	@Override
	public void configInterceptor(Interceptors me) {
		// TODO Auto-generated method stub
		
	}

	/* (non-Javadoc)
	 * @see com.jfinal.config.JFinalConfig#configHandler(com.jfinal.config.Handlers)
	 */
	@Override
	public void configHandler(Handlers me) {
		// TODO Auto-generated method stub
		me.add(new ContextPathHandler("contextPath"));
		
	}
	 

}
